/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package pkgjeudestrategie;

import java.awt.Color;
import java.awt.Graphics;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import javax.swing.ImageIcon;
import javax.swing.JComponent;

/**
 *
 * @author Admin
 */
public class EscButton extends JComponent {
Jeu jeu;
int move=-1;
boolean moving;
    public EscButton(Jeu j) {
        this.jeu=j;
        
        addMouseListener(new MouseAdapter() {

            @Override
            public void mouseClicked(MouseEvent e) {
                
              new FenetreMenuEsc(jeu);  

            }@Override
public void mouseEntered(MouseEvent e)
{
moving=true;
}
            @Override
public void mouseExited(MouseEvent e)
{
moving=false;
}
        });
        
    }
    
    
       public int isMoving() {
       move=-1;
        try {
            if (moving) {
                if (getMousePosition().getX() >= 0&&getMousePosition().getY()==0 ){
                    move=0;
                    if ( getMousePosition().getX() >=getWidth()-205 ) {
                     move= 1;
                } 
                }
                
                if (getMousePosition().getX() >=getWidth()-205 &&getMousePosition().getY() !=0) {
                     move= 2;
                } 
            }
        } catch (Exception e) {
        }

        return  move;
    
       
       
   }
    public void paintComponent(Graphics g) {
        g.setColor(Color.black);
        g.fillRect(0, 0, 550, 30);
        g.setColor(Color.white);
        g.drawString("Menu", 10, 10);
    }
}